
<script>
	function set_sim_view(slot){
			let sim_current_slot = slot["current_slot"];
			let sim_nextboot_slot = slot["nextboot_slot"];
			sim_current_view = document.getElementById("sim_slot_current");
			sim_nextboot_view = document.getElementById("sim_slot_nextboot");
			sim_current_view.innerHTML = sim_current_slot;
			sim_nextboot_view.innerHTML = sim_nextboot_slot;
		}

	function set_sim(){
		select = document.getElementById("sim_slot_select");
		slot = select.value;
		XHR.get('<%=luci.dispatcher.build_url("admin", "modem", "qmodem", "set_sim")%>', {"slot": slot },
			function (x, data) {
				set_sim_view(data);
			}
		);
	}

	window.onload=function(){
		XHR.get('<%=luci.dispatcher.build_url("admin", "modem", "qmodem", "get_sim")%>', null,
					function (x, data) {
						set_sim_view(data);
					}
				);
	}
</script>
<!-- 设置SIM卡槽 -->
	<div class="cbi-section" >
		<table class="table cbi-section-table">
			<tbody id="sim_slot_setting">
				<tr class="tr cbi-section-table-titles anonymous">
					<th>
						<%:SIM Slot%>|<%:Now%>
					</th>
					<th>
						<%:SIM Slot%>|<%:Next Boot%>
					</th>
					<th>
						<%:SIM Slot%>|<%:Setting%>
					</th>
				</tr>
				<tr class="tr">
					<td class="td" style="width: auto;">
						<span id="sim_slot_current"></span>
					</td>
					<td class="td cbi-value-field">
						<span id="sim_slot_nextboot"></span>
					</td>
					<td class="td cbi-value-field">
						<select name="sim_slot_select" id="sim_slot_select" class="cbi-input-select">
							<option value="SIM1"><%:SIM1 (Close to power)%></option>
							<option value="SIM2"><%:SIM2 (Away from power)%></option>

						</select>
					</td>
				</tr>
			</tbody>
		</table>
		<input type="button" class="cbi-button-apply" onclick="set_sim()" value="<%:Set SIM%>">

	</div>
